package com.unionfetch.content_home.bean

data class LiveAccountInfo(
    val buttonStatus: Boolean,
    val hasAudit: Boolean,
    val matTradesResps: MatTradesResps
)

data class MatTradesResps(
    val archived: List<LiveTradeAccount>,
    val disable: List<LiveTradeAccount>,
    val readOnly: List<LiveTradeAccount>,
    val running: List<LiveTradeAccount>
)

data class LiveTradeAccount(
    val accountType: Int?,
    val accountTypeName: String?,
    val archived: Any?,
    val auditDate: String,
    val balance: String?,
    val currency: String?,
    val equity: String?,
    val leverage: Int?,
    val mam: Boolean?,
    val netWorth: Any?,
    val pendingOrderWaiting: Int,
    val pendingOrdering: Int,
    val platform: Int,
    val profit: Any?,
    val serverId: Int?,
    val serverName: String?,
    val status: Int,
    val traderAccount: String
)

fun LiveTradeAccount.change2TradeAccountModel(): TradeAccountModel {
    return TradeAccountModel(
        type = AccountCategory.LIVE,
        status = this.status.findAccountStatus(),
        tradeNo = traderAccount,
        balance = if (this.balance == null) {
            Double.MIN_VALUE
        } else {
            this.balance.toDouble()
        },
        platform = this.platform,
        currency = this.currency ?: "-",
        serverName = this.serverName ?: "-",
        leverage = this.leverage ?: Int.MIN_VALUE,
        accountType = this.accountType ?: Int.MIN_VALUE,
        assets = if (this.equity == null) {
            Double.MIN_VALUE
        } else {
            this.equity.toDouble()
        },
        validity = Int.MAX_VALUE
    )
}